﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tunnel.Devices.DeviceEntity
{
    public partial class Wind : DeviceBase
    {
        decimal windSpeed;
        string windDirect;
        public Wind()
        {
            InitializeComponent();
            this.Size = new Size(64, 64);
        }

        public override string StatusDescription
        {
            get
            {
                return base.StatusDescription;
            }

            set
            {
                switch (value)
                {
                    case "正常":
                        {
                            this.Image = ResPic.风速风向正常;
                        }
                        break;
                    case "故障":
                        {
                            this.Image = ResPic.风速风向故障;
                        }
                        break;
                }
                base.StatusDescription = value;
            }
        }

        public decimal WindSpeed
        {
            get
            {
                return windSpeed;
            }

            set
            {
                windSpeed = value;
                this.windPanelShow.windSpeed.Text = value.ToString();
            }
        }

        public string WindDirect
        {
            get
            {
                return windDirect;
            }

            set
            {
                windDirect = value;
                switch (value)
                {
                    case "0": this.windPanelShow.windDirect.Text = "逆向"; break;
                    case "1": this.windPanelShow.windDirect.Text = "正向"; break;
                }
                //this.windPanelShow.windSpeed.Text = value;
            }
        }

        public override void SendCommand(CommandType commandType)
        {
            throw new NotImplementedException();
        }
        private void ShowPanel()
        {
            this.windPanelShow.Parent = this.Parent;
            this.windPanelShow.Location = new Point(this.Location.X - 35, this.Location.Y + 65);
            this.windPanelShow.BringToFront();
            this.windPanelShow.Show();
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            ShowPanel();
        }
    }
}
